package com.tenglong.teacher.data;

import android.content.Context;

/**
 * @author hdx on 2019/3/26.
 */
public abstract class ConfigEditor {
    public static String readStringPref(Context context, String prefName, String key, String defValue) {
        return context.getSharedPreferences(prefName, Context.MODE_PRIVATE).getString(key, defValue);
    }

    public static void writeStringPref(Context context, String preName, String key, String value) {
        context.getSharedPreferences(preName, Context.MODE_PRIVATE).edit().putString(key, value).commit();
    }

    public static Long readLongPref(Context context, String prefName, String key, long defValue) {
        return context.getSharedPreferences(prefName, Context.MODE_PRIVATE).getLong(key, defValue);
    }

    public static void writeLongPref(Context context, String preName, String key, long value) {
        context.getSharedPreferences(preName, Context.MODE_PRIVATE).edit().putLong(key, value).commit();
    }

    public static int readIntPref(Context context, String prefName, String key, int defValue) {
        return context.getSharedPreferences(prefName, Context.MODE_PRIVATE).getInt(key, defValue);
    }

    public static void writeIntPref(Context context, String preName, String key, int value) {
        context.getSharedPreferences(preName, Context.MODE_PRIVATE).edit().putInt(key, value).commit();
    }

    static Boolean readBooleanPref(Context context, String prefName, String key, Boolean defValue) {
        return context.getSharedPreferences(prefName, Context.MODE_PRIVATE).getBoolean(key, defValue);
    }

    static void writeBooleanPref(Context context, String preName, String key, Boolean value) {
        context.getSharedPreferences(preName, Context.MODE_PRIVATE).edit().putBoolean(key, value).commit();
    }

    public static void remove(Context context, String preName, String key) {
        context.getSharedPreferences(preName, Context.MODE_PRIVATE).edit().remove(key).commit();
    }
}
